<%@ page pageEncoding="UTF-8" %>
<script src="<c:url value='/resources/js/manage.js'/>"></script>
<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
    <c:param name="title" value="投诉列表"/>
    <c:param name="body">
        <script>
            $(document).ready(
                    function () {
                        var id = $(".id").val();
                        if (id) {

                        }

                    });
        </script>


        <div class="content-title">投诉列表
            <p>${message.msg}</p>
        </div>
        <div class="container"
             style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
            <c:if test="${message!=null}">
                <div class="alert alert-danger" role="alert">${message.msg}</div>
            </c:if>
            <p></p>

            <div class="col-sm-5 col-sm-offset-1">
                <form id="searchForm" method="get" action="/system/complaint/list"
                      name="complaint">
                    <div class="input-group pull-left" style="margin-bottom:8px;">
                        查询：<a class="btn btn-primary btn-xs" href="/system/complaint/list?acceptResult=1">受理</a>
                        <a class="btn btn-primary btn-xs" href="/system/complaint/list?acceptResult=0">未受理</a>
                    </div>
                    <div class="input-group">
                        <input id="pageNo" name="pageNo" type="hidden" value="${pager.pageNo}"/>
                        <input id="pageSize" name="pageSize" type="hidden" value="${pager.pageSize}"/>


                    </div>
                </form>
            </div>

            <div class="main-content">

                <table class="table">
                    <thead>
                    <tr>
                        <th>投诉原因</th>
                        <th>投诉时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${pager.list}" var="complaint">
                        <tr class="success">
                            <td><a href="#" onclick="showDetail('<c:url
                                    value="/system/complaint/getComplaint?id=${complaint.id}"/>')" data-toggle="modal"
                                   data-target="#showDetail">
                                <c:if test="${complaint.complaintReason.length() gt 10}">
                                ${complaint.complaintReason.substring(0,10)}......
                                </c:if>
                                <c:if test="${complaint.complaintReason.length() le 10}">
                                    ${complaint.complaintReason}
                                </c:if>
                            </a></td>
                            <td>${complaint.complaintTime}</td>
                            <td>
                                <c:if test="${complaint.acceptResult == 1}">
                                    <button class="btn btn-primary btn-xs"
                                            data-toggle="modal" data-target="#">已受理
                                    </button>
                                </c:if>
                                <c:if test="${complaint.acceptResult == 0}">
                                    <a class="btn btn-primary btn-xs"
                                       href="/system/complaint/accept?id=${complaint.id}">受理
                                    </a>
                                </c:if>
                                <button class="btn btn-primary btn-xs"
                                        href="javascript:void(0)" data-toggle="tooltip" title="删除"
                                        onclick="if (confirm('确认要删除本记录吗？此操作将不可恢复！'))
                                                location = '<c:url
                                                value="/system/complaint/delete?id=${complaint.id}"/>';
                                                return false;">删除
                                </button>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <div class="row">
                <div class="col-sm-12">
                        ${pager}
                </div>
            </div>
        </div>
        <script type="text/javascript">

            function showDetail(path) {
                $.ajax({
                    url: path,
                    type: 'get',
                    async: true,
                    dataType: 'json',
                    success: function (complaint) {
                        alert(complaint.id);
                        $('#edit_complaintName').html(complaint.username);
                        $('#edit_complaintReason').html(complaint.complaintReason);
                        $('#edit_complaintTime').html(complaint.complaintTime);
                        $('#edit_acceptTime').html(complaint.acceptTime);
                    }
                });
            }


        </script>
        <%--编辑修改模态框--%>
        <div class="modal fade" id="showDetail" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">
                            <span aria-hidden="true">&times;</span>
                            <span class="sr-only">Close</span>
                        </button>
                        <h3 class="modal-title">详细内容</h3>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="control-label" for="edit_complaintName">投诉人</label>
                            <span type="text" class="form-control" id="edit_complaintName"></span>
                        </div>
                        <div class="form-group">
                            <label for="edit_complaintReason">投诉原因</label>
                            <span class="form-control" id="edit_complaintReason"></span>
                        </div>
                        <%--<div class="form-group">
                            <label for="edit_complaintImage">图片</label>
                            <img src="#" class="form-control" id="edit_complaintImage"/>
                        </div>--%>
                        <div class="form-group">
                        <label for="edit_complaintTime">投诉时间</label>
                        <span class="form-control" id="edit_complaintTime"></span>
                        </div>
                        <div class="form-group">
                            <label for="edit_acceptTime">受理时间</label>
                            <span class="form-control" id="edit_acceptTime"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </c:param>
</c:import>
